<?php
$month          = date("m");
$year           = date("Y");
$id				= gpc_getIntPost("id",$id);
$Status			= gpc_getIntPost("Status");
$Url			= gpc_getStringPost("Url");
$Title			= gpc_getStringPost("Title");
$ImgIntro       = gpc_getStringPost("ImgIntro");
$ImgIntroThumb  = gpc_getStringPost("ImgIntroThumb");
$Message    	= gpc_getStringPost("Message");
$Footer      	= gpc_getStringPost("Footer");

$metatitle 		= gpc_getStringPost("MetaTitle",$Title);
$metakeywords 	= gpc_getStringPost("MetaKeywords");
$metadescription= gpc_getStringPost("MetaDescription",strip_tags($Message));


$Message        = replace_pathlocal($Message);
$Footer         = replace_pathlocal($Footer);

$Url            = Trim_Url($Url,$Title);

if($act=='insert')
{
    $sql_insert="insert into tblnewsletter(iMonth,iYear,cName,cUrlString,cImageThumb,cImage,cDescription,cFooter,
                iStatus,cLanguage,cMetaTitle, cMetaDescription, cMetaKeywords) 
                values('$month','$year','$Title','$Url','$ImgIntroThumb','$ImgIntro','$Message','$Footer',
                0,'$language','$metatitle','$metadescription','$metakeywords')";
	$dbsql->query($sql_insert);
    $id = $dbsql->insert_id();
    
    page_transfer("Add newsletter Success",'?module='.$module.'&opt=content&id='.$id);
}
else if($id>0)
{
    $sql_update = "update tblnewsletter set ";
    $sql_update.= " cUrlString      = '$Url',";
    $sql_update.= " cName           = '$Title',";
    $sql_update.= " cImageThumb     = '$ImgIntroThumb',";
    $sql_update.= " cImage          = '$ImgIntro',";
    $sql_update.= " cDescription    = '$Message',";
    $sql_update.= " cFooter         = '$Footer',";
    $sql_update.= " cMetaTitle      = '$metatitle',";
    $sql_update.= " cMetaDescription= '$metadescription',";
    $sql_update.= " cMetaKeywords   = '$metakeywords',";
    $sql_update.= " iStatus         = '$Status'";
    $sql_update.= " where iId       = '$id'";
    $dbsql->query($sql_update);
    
    page_transfer("Update newsletter Success",getUrlBack());
}
exit;
?>